import java.util.*;

class Book implements Comparable<Book>{
    public String bookName;
    public Integer bookId;
    public Double bookPrice;
    public Book next;
    public Book(String bookName, Integer bookId, Double bookPrice) {
        this.bookName = bookName;
        this.bookId = bookId;
        this.bookPrice = bookPrice;
    }

    @Override
    public int compareTo(Book o) {
        return (int) (this.bookPrice-o.bookPrice);
    }
}
public class Main {
    public static Book head;
    public static Book prev;
    public static void test1(){
        Scanner scanner = new Scanner(System.in);
        int count = 0;
        while(true){
            String message = scanner.nextLine();
            if(message.equals("0 0 0")){
                break;
            }
            String[] tmp = message.split(" ");
            int id = Integer.parseInt(tmp[0]);
            String name = tmp[1];
            double price = Double.parseDouble(tmp[2]);
            Book book = new Book(name,id,price);
            if(head==null){
                head = book;
                prev = book;
                count++;
            }else{
                prev.next = book;
                prev = book;
                count++;
            }
        }
        System.out.println(count);
        Book cur = head;
        while(cur!=null) {
            System.out.println(cur.bookId + " " + cur.bookName + " " + cur.bookPrice);
            cur = cur.next;
            count--;
        }
    }
    public static void main(String[] args) {
       test1();
       test2();
       test3();
       test4();
       test5();
    }
    private static void test5() {
        Scanner scanner = new Scanner(System.in);
        int count = 0;
        List<Book>list = new ArrayList<>();
        Book max1 = null ;
        double max2 = 0;
        while(true) {
            String message = scanner.nextLine();
            if (message.equals("0 0 0")) {
                break;
            }
            String[] tmp = message.split(" ");
            int id = Integer.parseInt(tmp[0]);
            String name = tmp[1];
            double price = Double.parseDouble(tmp[2]);

            Book book = new Book(name, id, price);
            if(price>max2){
                max2 = price;
                max1 = book;
            }
        }
            Book cur = max1;
            System.out.println(cur.bookId + " " + cur.bookName + " " + cur.bookPrice);
    }

    private static void test4() {
        Scanner scanner = new Scanner(System.in);
        int count = 0;
        List<Book>list = new ArrayList<>();
        double sum = 0;
        while(true) {
            String message = scanner.nextLine();
            if (message.equals("0 0 0")) {
                break;
            }
            String[] tmp = message.split(" ");
            int id = Integer.parseInt(tmp[0]);
            String name = tmp[1];
            double price = Double.parseDouble(tmp[2]);
            sum+=price;
            Book book = new Book(name, id, price);
            list.add(book);
        }
        Collections.reverse(list);
        for(Book book :list){
            Book cur = book;
            System.out.println(cur.bookId + " " + cur.bookName + " " + cur.bookPrice);
        }
    }

    private static void test3() {
        Scanner scanner = new Scanner(System.in);
        int count = 0;
        List<Book>list = new ArrayList<>();
        double sum = 0;
        while(true) {
            String message = scanner.nextLine();
            if (message.equals("0 0 0")) {
                break;
            }
            String[] tmp = message.split(" ");
            int id = Integer.parseInt(tmp[0]);
            String name = tmp[1];
            double price = Double.parseDouble(tmp[2]);
            sum+=price;
            Book book = new Book(name, id, price);
            list.add(book);
        }
        double avg = sum/list.size();
        for(Book book :list){
            Book cur = book;
            if(cur.bookPrice>avg){
                cur.bookPrice = cur.bookPrice+cur.bookPrice/10.0;
            }else{
                cur.bookPrice = cur.bookPrice+cur.bookPrice/5.0;
            }
            System.out.println(cur.bookId + " " + cur.bookName + " " + cur.bookPrice);
        }
    }

    private static void test2() {
        Scanner scanner = new Scanner(System.in);
        int count = 0;
        List<Book>list = new ArrayList<>();
        while(true) {
            String message = scanner.nextLine();
            if (message.equals("0 0 0")) {
                break;
            }
            String[] tmp = message.split(" ");
            int id = Integer.parseInt(tmp[0]);
            String name = tmp[1];
            double price = Double.parseDouble(tmp[2]);
            Book book = new Book(name, id, price);
            list.add(book);
        }
        Arrays.sort(new List[]{list});
        for(Book book :list){
            Book cur = book;
            System.out.println(cur.bookId + " " + cur.bookName + " " + cur.bookPrice);
        }
    }
}